<?php

/*

  Action	$6

  +1 Card; +1 Action; +1 Buy; +$2
  You can’t buy this if you have any Copper in play.

 */

class GrandMarket extends Card implements iAction, iKingdom, iProsperity {

    public function __construct() {
        parent::__construct("Grand Market", 6);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "+1 Card",
            "+1 Action",
            "+1 Buy",
            "+$2",
            "You can’t buy this if you have any Copper in play.");
    }

    public function play(Game $game, $isRealCard) {
        $drawed_cards = $game->drawCards(1);
        $game->addActions(1);
        $game->addBuys(1);
        $game->addMoney(new Price(2));
        ScreenDisplay::addScreenMessage($game, true, "get +1 action, +1 buy,  +2$ and draw " . nicePrint($drawed_cards), "get +1 action, +1 buy,  +2$ and draws " . sizeof($drawed_cards) . " cards");
        $game->cardActionFinished();
        return true;
    }

    public function getPrice($game) {
        if ($game == null)
            return $this->price;
        $phase = $game->getPhase();
        if ($phase == Phase_Buy || $phase == Phase_Payment) {
            $playArea = $game->getPlayArea();
            $copper = new Copper();
            foreach ($playArea as $card) {
                if ($card->getKey() == $copper->getKey()) {
                    return new Price(PHP_INT_MAX, PHP_INT_MAX);
                }
            }
        }
        return $this->price;
    }

}

?>